<script src="__STATIC__/js/ajax_file_upload.js" type="text/javascript"></script> 
<script type="text/javascript" src="__STATIC__/js/jquery.ui.widget.js" charset="utf-8"></script>
<script type="text/javascript" src="__STATIC__/js/jquery.fileupload.js" charset="utf-8"></script>
<div class="upload-con" id="uploader" style="display:none;overflow:auto;height:350px;width:185px;">
	<div class="js-file-msg"></div>
	<div class="upload-pmgressbar js-file-loading"></div>
	<div class="upload-txt"><span>支持Jpg、Png格式，大小不超过1024KB的图片上传；浏览文件时可以按住ctrl或shift键多选。</span></div>
</div>
<script type="text/javascript">
$(function() {
	//鼠标触及区域li改变class
	var album_id = $("#album_id").val();
	var dataAlbum = {
		"album_id" : album_id,
		"thumb_type" : "big,mid,small,thumb",
		'file_path' : "system"
	};
	// ajax 上传图片
	var upload_num = 0; // 上传图片成功数量
	$('#fileupload').fileupload({
		url: "{:__URL('ADMIN_MAIN/system/imagetoalbum')}",
		dataType: 'json',
		formData:dataAlbum,
		add: function (e,data) {
			//显示上传图片框
			if($("#uploader").is(":hidden")){
				$("#uploader").show();
			}
			$.each(data.files, function (index, file) {
				$('<div data-name="' + file.name + '"><p>'+ file.name +'</p><p class="loading"></p></div>').appendTo('.js-file-loading');
			});
			data.submit();
		},
		done: function (e,data) {
			var param = data.result;
			$this = $('div[data-name="' + param.data.file_name + "." + param.data.file_ext + '"]');
			$this.fadeOut(3000, function(){
				$(this).remove();
				if ($('.js-file-loading').html() == '') {
					$("#uploader").hide();
					LoadingInfo(1);
				}
			});
			if(param.code > 0){
				upload_num++;
				$('.js-file-msg').html('<i class="icon-ok-sign">'+'</i>'+'成功上传'+upload_num+'张图片');
			} else {
				showTip(param.message,"warning");
				$this.find('.loading').html(param.message).removeClass('loading');
			}
		}
	});
});
</script>